package org.nerve.webmagic.utils;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * org.nerve.webmagic.utils
 * Created by zengxm on 2016/4/20 0020.
 */
public class DirUtil {

	public static final String PATH;

	static {
		String strRealPath  = DirUtil.class.getClassLoader().getResource(".").getFile();
		try {
			strRealPath = URLDecoder.decode(strRealPath, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}

		File objFile = new File(strRealPath);
		PATH=objFile.getAbsolutePath();
	}

	public static String get(String location){
		return PATH+location;
	}
	public static Path getPath(String location){
		return Paths.get(PATH, location);
	}
}
